package com.jd.sunny.java;

import java.text.NumberFormat;
import java.text.ParseException;

/**
 * @Description:test java wrapper class
 * @author:sunlin
 * @since:2012-11-28 13:26
 * @version:1.0.0
 */
public class TestWrapperClass {
    public static void main(String[] args) throws ParseException {

        testInteger();

        testNumberFormat();
    }

    /**
     * test Integer
     */
    public static void testInteger(){
        Integer a = 100;
        Integer b = 100;
        Integer c = new Integer(100);
        Integer d = new Integer("100");
        Integer f = new Integer(100);

        System.out.println("a==b : " + (a==b)) ;
        System.out.println("a.equals(b) : " + (a.equals(b))) ;
        System.out.println("c==d : " + (c==d)) ;
        System.out.println("c.equals(d) : " + (c.equals(d))) ;
        System.out.println("c==f : " + (c==f)) ;
        System.out.println("c.equals(f) : " + (c.equals(f))) ;

        // return intValue
        int intValue = c.intValue();

        //parse Inteer to  int
        int i = Integer.parseInt("30");

        //parse string to Integer
        Integer integer = Integer.valueOf("20");

    }

    /**
     * test NumberFormat
     */
    public static void testNumberFormat() throws ParseException {
        Number number =  NumberFormat.getInstance().parse("20");
        System.out.println("number = " + number);
    }

}
